/*******
author: sailing
date: 2017/1/18
*********/
import startcy from './initApp'
export default {

	uploadComplete () {
		startcy.start()
	},

	uploadFailed () {
		console.log('uploadError')
	},

	progressFunction (evt) {
	  var vm = evt.vm
      this.vm.uploadLen = Math.round(evt.loaded / evt.total * 100)
	},

	load (vm, file) {
      var form = new FormData()
      form.append('excel', file)
      var url = '/cable/importdata/'
      var xhr = new XMLHttpRequest()
      xhr.open('post', url, true)
      xhr.onload = this.uploadComplete
      xhr.upload.vm = vm
      xhr.onerror =  this.uploadFailed
      xhr.upload.onprogress = this.progressFunction
      xhr.send(form)
	}
}
